home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / demos / anim / anim6.sci < prev    next >
Text File  |  1999-09-16  |  764b  |  33 lines

  1. function chaina(yt)
  2. [n1,n2]=size(yt);
  3. x=ones(n1/2,n2);
  4. y=ones(n1/2,n2);
  5. x(1,:)=2*r(1)*cos(yt(1,:));
  6. y(1,:)=2*r(1)*sin(yt(1,:));
  7. for i=2:n1/2, 
  8.   x(i,:)=x(i-1,:)+2*r(i)*cos(yt(i,:));
  9.   y(i,:)=y(i-1,:)+2*r(i)*sin(yt(i,:));
  10. end
  11. x=[0*ones(1,n2);x];
  12. y=[0*ones(1,n2);y];
  13. rr=r(1)/(n1+1);
  14. rect=2*[-(n1/2+1),-(n1/2+1),n1/2+1,n1/2+1];
  15. plot2d(0,0,[0],"012"," ",rect);
  16. for j=1:n2,
  17.   xset("wwpc");chaind([x(:,j),y(:,j)],rr,rect);
  18.   xset("wshow");
  19. end
  20.  
  21. function chaind(p,r,rect)
  22. //draw chain given sequence of points
  23. //!
  24. [n,ign]=size(p);
  25. th=xget("thickness");
  26. xset("thickness",1)
  27. arcs=[ -r ,r,2*r,2*r,0,64*360].*.ones(n,1);
  28. arcs=[ p, 0*ones(n,4)] + arcs;
  29. xarcs(arcs');
  30. xset("thickness",4);
  31. xpolys([p(1:(n-1),1),p(2:n,1)]',[p(1:(n-1),2),p(2:n,2)]',-(1:n));
  32. xset("thickness",th);
  33.